#include  "emtools.h"
#include	"ctype.h"

string TrimAll(string &SourceString)
{
  unsigned char ch;
  string TargetString;
  int len=SourceString.size();
  if(len<=0)
    return TargetString;
  int nStart=0;
  int nEnd=len-1;
  do
  {
    ch=(unsigned char)SourceString[nStart];
    if((ch>0x20)||(((char)ch)<0))
      break;
    nStart++;
  }
  while(nStart<len-1);
  do
  {
      ch=(unsigned char)SourceString[nEnd];
      if((ch>0x20)||(((char)ch)<0))
        break;
      nEnd--;
  }
  while(nEnd>=0);
  TargetString=SourceString.substr(nStart,nEnd+1);
  return TargetString;
}

string UpString(string & SourceString)
{
	
	string NewStr;
	char localCh;
	int i;
	for(i=0;i<SourceString.size();i++)
	{
		localCh=SourceString[i];
		localCh=toupper(localCh);
		NewStr+=(char)(unsigned int)localCh;
	}
	return NewStr;
}

string LowerString(string & SourceString)
{

    string NewStr;
    char localCh;
    int i;
    for(i=0;i<SourceString.size();i++)
    {
        localCh=SourceString[i];
        localCh=tolower(localCh);
        NewStr+=(char)(unsigned int)localCh;
    }
    return NewStr;
}
